﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AutoEditUI.UserControls
{
    /// <summary>
    /// LineProp.xaml 的交互逻辑
    /// </summary>
    public partial class LineProp : UserControl
    {
        public LineProp()
        {
            InitializeComponent();
        }

        public UIItem gUIItem { get; private set; }

        internal void Bind(MainWindow mainWindow, Rectangle x)
        {
            gUIItem = (UIItem)mainWindow.GeItemByTag((string)x.Tag);
            localrelate.SetItm(mainWindow, gUIItem, x);
            TextBlockTag.Text = x.Tag.ToString();
            TextBoxW.Text = x.Width.ToString();
            TextBoxH.Text = x.Height.ToString();

            TextBlockTag.Text = x.Tag.ToString();
            TextBoxW.Text = x.Width.ToString();
            TextBoxH.Text = x.Height.ToString();
            // TextBoxTextSize.Text = x.FontSize.ToString();
            //TextBoxSource.Text = x.Source.ToString();
            // x.SetBinding(TextBlock.TextProperty, new Binding("Text") { Source = TextBoxText });
            x.SetBinding(Rectangle.WidthProperty, new Binding("Text") { Source = TextBoxW });
            x.SetBinding(Rectangle.HeightProperty, new Binding("Text") { Source = TextBoxH });
            //  x.SetBinding(Image.SourceProperty, new Binding("Text") { Source = TextBoxSource });
            // x.SetBinding(TextBlock.FontFamilyProperty, new Binding("Text") { Source = TextBoxFont });

            X.Text = x.GetValue(Canvas.LeftProperty).ToString();
            Y.Text = x.GetValue(Canvas.TopProperty).ToString();

            Binding xxx = new Binding("Text") { Source = X };
            xxx.Mode = BindingMode.TwoWay;
            x.SetBinding(Canvas.LeftProperty, xxx);

            Binding yyy = new Binding("Text") { Source = Y };
            yyy.Mode = BindingMode.TwoWay;
            x.SetBinding(Canvas.TopProperty, yyy);

            TextBoxName.Text = x.Name.ToString();
            x.SetBinding(Image.NameProperty, new Binding("Text") { Source = TextBoxName });
        }
    }
}
